from django.db import models

# Create your models here.
from django.db import models

class TeacherCourseClass(models.Model):
    """教师授课班级中间表"""
    teacher = models.ForeignKey('teacher.Teacher', on_delete=models.CASCADE, verbose_name='教师')
    course = models.ForeignKey('course.Course', on_delete=models.CASCADE, verbose_name='课程')
    clazz = models.ForeignKey('clazz.Clazz', on_delete=models.CASCADE, verbose_name='授课班级')
    school_year = models.CharField(max_length=20, blank=True, verbose_name='学年')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')

    class Meta:
        db_table = 'tb_teacher_course_class'
        unique_together = ('teacher', 'course', 'clazz')   # 同一老师同一门课在同一班只出现一次
        verbose_name = '教师授课班级'
        verbose_name_plural = verbose_name

    def __str__(self):
        return f'{self.teacher.name} | {self.course.name} | {self.clazz.name}'